package com.gdut.huayan.constant;

import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;

public class WechatConstant {
    public static final String NOTIFY_URL = "https://api.huayan-temple.cn/order/callback/hrk2ug328XCHfs24l";

    public static final String REFUND_CALL_URL = "https://api.huayan-temple.cn/refund/callback/df698gtiu31s8fhp";

    public static String ACCESS_TOKEN;

    public final static String APP_ID = "wxa43c46fa14c1ef9b";

    public final static String APP_SECRET = "6cf2d66cfefda48e57bb2fe417ed907a";

    public final static String ORDER_PREFIX = "ORDER-";

//    public final static long THIRTY_MINUTES = 1860000;

    //商户号
    public final static String MCH_ID = "1628703046";

    //商户序列号
//    public final static String MCH_SERIAL_NUMBER = "4F4B4F8DC4BFB2E969D073839C00BF238ABDAF67";

    //私钥 PemUtil.loadPrivateKey("")
    public static PrivateKey MCH_PRIVATE_KEY;

    static {
        try {
            // TODO:需要改路径
            //String bathPath = "/Users/sichengzhao/IdeaProjects/huayan2/src/main/resources/";
            MCH_PRIVATE_KEY = PemUtil.loadPrivateKey(new FileInputStream(new File( "wechat/apiclient_key.pem").getAbsolutePath()));
            WC_PAY_CERTIFICATES = PemUtil.loadCertificate(new FileInputStream(new File("wechat/apiclient_cert.pem").getAbsolutePath()));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    //证书
    public static X509Certificate WC_PAY_CERTIFICATES;

//    public final static String SELECT_ORDER_URL = " https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}?mchid=" + MCH_ID;

    public final static String PAY_URL = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";

    public final static String GET_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + APP_ID + "&secret=" + APP_SECRET;

    public final static  String REFUND_URL = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds";

    public final static String API_V3_KEY = "zaIC7KsjR3tupYX4FTdEMz1P1ezEYMli";

    public final static String NONCE = "Wechatpay-Nonce";

    public final static String TIMESTAMP = "Wechatpay-Timestamp";

    public final static String SIGNATURE = "Wechatpay-Signature";

    public final static String SERIAL = "Wechatpay-Serial";

}
